package top.superflow.core.metadata

import top.superflow.core.api.ShowSelf
import top.superflow.lang.CollectionUtils

import scala.collection.mutable

trait MetadataAble extends ShowSelf{


  protected val metadata : mutable.Map[String, Any] = mutable.Map()

  def getMetadata : Map[String, Any] = this.metadata.toMap

  def setMetadata (m : Map[String, Any]): Unit = {
    metadata.clear()
    this.metadata ++= m
  }

  def mergeMetadata(newMetadata : Map[String, Any]): Unit ={
    if(CollectionUtils.isEmpty(newMetadata)){
      return
    }

    this.metadata ++= newMetadata
  }
}